package com.ailatrieuphu.sprite;

import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.text.Text;
import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.font.Font;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.color.Color;

import com.ailatrieuphu.item.Player;

import android.util.Log;

public class PlayerSprite extends Sprite {
	Player player;
	Text text;
	Font mFont;

	public PlayerSprite(float pX, float pY, ITextureRegion pTextureRegion,
			VertexBufferObjectManager pVertexBufferObjectManager) {
		super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
	}

	@Override
	public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
			float pTouchAreaLocalX, float pTouchAreaLocalY) {
		if (TouchEvent.ACTION_DOWN == pSceneTouchEvent.getAction()) {
			Log.e("Pos ", pTouchAreaLocalX + " , " + pTouchAreaLocalY + "----"
					+ pSceneTouchEvent.getX() + " , " + pSceneTouchEvent.getY());
		}
		return true;
	}

	public void paint() {
		text = new Text(0, 0, mFont, player.getName(),
				this.getVertexBufferObjectManager());
		float width = text.getWidth();
		text.setPosition(-width / 2 + this.getWidth() / 2, 0);
		this.attachChild(text);
	}

	public Player getPlayer() {
		return player;
	}

	public void setPlayer(Player player) {
		this.player = player;
	}

	public Text getText() {
		return text;
	}

	public void setText(Text text) {
		this.text = text;
	}

	public Font getmFont() {
		return mFont;
	}

	public void setmFont(Font mFont) {
		this.mFont = mFont;
	}

	public void update() {

	}
}
